/**
 * Created by jimmy on 17/2/26.
 */

// var Base = require('../../utils/base.js').base;
import { Base } from '../../utils/base.js';

class Home extends Base {
  constructor() {
    super();
  }
  //进入首页在home参数后面生成自己的uid作为值
  getUid(callback) {
    this.request({
      url: 'getUid',
      type: 'get',

      header: {
        'content-type': 'application/x-www-form-urlencoded',
        'token': wx.getStorageSync('token')
      },
      sCallback: function (data) {
        callback && callback(data);
      },
      eCallback: function (data) {
      }
    })
  }
  setPid(param, callback) {
    this.request({
      url: 'setPid',
      type: 'post',
      data: param,
      header: {
        'content-type': 'application/x-www-form-urlencoded',

      },
      sCallback: function (data) {
        callback && callback(data);
      },
      eCallback: function (data) {
      }
    })
  }
  staticImg(callback) {
    this.request({
      url: 'staticImg',
      type: 'get',

      header: {
        'content-type': 'application/x-www-form-urlencoded',
        
      },
      sCallback: function (data) {
        callback && callback(data);
      },
      eCallback: function (data) {
      }
    })
  }
  /*banner图片信息*/
  getBannerData(callback) {
    var that = this;
    var param = {
      url: 'banner/1',
      header: {
        'content-type': 'application/json',
        'token': wx.getStorageSync('token')
      },
      sCallback: function (data) {
        data = data.items;
        callback && callback(data);
      }
    };
    this.request(param);
  }
  /*首页主题*/
  getThemeData(callback) {
    var param = {
      url: 'theme?ids=1,2,3',
      header: {
        'content-type': 'application/json',
        'token': wx.getStorageSync('token')
      },
      sCallback: function (data) {
        callback && callback(data);
      }
    };
    this.request(param);
  }

  /*首页部分商品*/
  getProductorData(callback) {
    var param = {
      url: 'product/recent',
      header: {
        'content-type': 'application/json',
        'token': wx.getStorageSync('token')
      },
      sCallback: function (data) {
        callback && callback(data);
      }
    };
    this.request(param);
  }
};

export { Home };